home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / ANIVGA.ARJ / EXAMPLE3.PAS < prev    next >
Pascal/Delphi Source File  |  1991-11-09  |  2KB  |  73 lines

  1. PROGRAM Example3;
  2.  
  3. {Demonstrates the use of the Display_SHADOW mode, GetImage() and PutImage() }
  4. {The same sprite is loaded twice (with different LOADnumbers) so that it can}
  5. {be used with different display modes. The shadow zone is done by redrawing }
  6. {the flower with display mode "Display_SHADOW" two pixels to the right and  }
  7. {below the flower drawn with display mode "Display_NORMAL"; note that the   }
  8. {outline of the shadow doesn't fully behave as wanted. To improve, one had  }
  9. {to draw one (several (?)) shadow sprites especially designed for the flower}
  10.  
  11. USES ANIVGA,CRT;
  12. CONST Sprite_Name='flower.COD';
  13.       Flower=10;
  14.       FlowerShadow=11;
  15.  
  16. VAR ch:Char;
  17.     i,j:Integer;
  18.     temp:WORD;
  19.     p1:POINTER;
  20.  
  21. BEGIN
  22.  
  23.  IF (loadSprite(Sprite_Name,Flower)=0) OR     {load sprite 2x for different}
  24.     (loadSprite(Sprite_Name,FlowerShadow)=0)  {display modes!}
  25.   THEN BEGIN
  26.         WRITELN(GetErrorMessage); halt(1)
  27.        END;
  28.  
  29.  SetModeByte(FlowerShadow,Display_SHADOW); {set mode of shadow sprite}
  30.  
  31.  InitGraph;
  32.  
  33.  FOR i:=15 TO 78 DO
  34.   BEGIN {draw some colors on the screen}
  35.    Color:=i;
  36.    FOR j:=(i-15)*5 TO (i-15)*5+4 DO BackgroundLine(j,0,j,YMAX)
  37.   END;
  38.  
  39.  SpriteN[0]:=Flower; SpriteX[0]:=100; SpriteY[0]:=100;
  40.  {Use same flower for shadow zone:}
  41.  SpriteN[1]:=FlowerShadow;
  42.  SpriteX[1]:=SpriteX[0]+2; SpriteY[1]:=SpriteY[0]+2;
  43.  
  44.  WHILE keypressed DO ch:=readkey;
  45.  Animate;
  46.  REPEAT
  47.   if keypressed
  48.    THEN BEGIN
  49.          while keypressed do ch:=upcase(readkey);
  50.          case ch of
  51.           'C':BEGIN
  52.                p1:=GetImage(0,0,50,30,1-PAGE);
  53.                PutImage(-10,-5,p1,BACKGNDPAGE);
  54.                PutImage(-11,60,p1,BACKGNDPAGE);
  55.                PutImage(-12,110,p1,BACKGNDPAGE);
  56.                PutImage(-13,180,p1,BACKGNDPAGE);
  57.                Dispose(p1);
  58.               END;
  59.           'P':FOR i:=1 TO 1000 DO
  60.                BackgroundPutPixel(Random(XMAX+1),Random(YMAX+1),Random(256));
  61.           'I':BEGIN dec(SpriteY[0]); dec(SpriteY[1]) END;
  62.           'J':BEGIN dec(SpriteX[0]); dec(SpriteX[1]) END;
  63.           'K':BEGIN inc(SpriteX[0]); inc(SpriteX[1]) END;
  64.           'M':BEGIN inc(SpriteY[0]); inc(SpriteY[1]) END;
  65.          end;
  66.          if pos(ch,'PCIJKM')>0 THEN Animate;
  67.         END;
  68.  
  69.  UNTIL ch='Q';
  70.  
  71.  CloseRoutines;
  72.  
  73. END.